package smtpserver

import (
	"net"
	"time"

	"github.com/nosch/smtpoll/config"
)

// Connection 抽象网络连接接口
type Connection interface {
	Read([]byte) (int, error)
	Write([]byte) (int, error)
	Close() error
	RemoteAddr() net.Addr
	LocalAddr() net.Addr
	SetReadDeadline(time.Time) error
	SetWriteDeadline(time.Time) error
	SetDeadline(time.Time) error
}

// SessionState 定义会话状态接口
type SessionState interface {
	HandleCommand(session *Session, command string) error
	GetName() string
}

// ServerOptions 服务器配置选项
type ServerOptions struct {
	Host         string
	Ports        []int
	TLSConfig    *config.TLSConfig
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	MaxConn      int
	NetworkLib   string // 使用的网络库：netpoll、gnet、net
}

// MessageHandler 消息处理接口
type MessageHandler interface {
	HandleMessage(*Message) error
}

// Server 服务器接口
type Server interface {
	Run() error
	Stop() error
	GetOptions() *ServerOptions
}
